<template>
  <MainLayout>
    <view class="settings-page">
      <view class="settings-header">
        <text class="header-title">设置</text>
      </view>
      
      <view class="settings-content">
        <!-- 设置项列表 -->
        <view class="settings-item">
          <text class="item-label">账号与安全</text>
          <image class="arrow-icon" src="/static/icons/right-arrow.svg" mode="aspectFit"></image>
        </view>
        
        <view class="settings-item">
          <text class="item-label">隐私设置</text>
          <image class="arrow-icon" src="/static/icons/right-arrow.svg" mode="aspectFit"></image>
        </view>
        
        <view class="settings-item">
          <text class="item-label">通知设置</text>
          <image class="arrow-icon" src="/static/icons/right-arrow.svg" mode="aspectFit"></image>
        </view>
        
        <view class="settings-item">
          <text class="item-label">通用设置</text>
          <image class="arrow-icon" src="/static/icons/right-arrow.svg" mode="aspectFit"></image>
        </view>
        
        <view class="settings-item">
          <text class="item-label">关于我们</text>
          <image class="arrow-icon" src="/static/icons/right-arrow.svg" mode="aspectFit"></image>
        </view>
      </view>
      
      <!-- 登出按钮 -->
      <view class="logout-section">
        <button class="logout-button" @click="handleLogout">退出登录</button>
      </view>
    </view>
  </MainLayout>
</template>

<script setup>
import MainLayout from '../../layout/MainLayout.vue';

const handleLogout = () => {
  uni.showModal({
    title: '提示',
    content: '确定要退出登录吗？',
    success: function (res) {
      if (res.confirm) {
        // 清除本地存储的用户信息
        uni.removeStorageSync('token');
        uni.removeStorageSync('userInfo');
        uni.removeStorageSync('userId');
        
        // 返回到我的页面或登录页面
        uni.reLaunch({
          url: '/pages/mine/mine'
        });
      }
    }
  });
};
</script>

<style scoped>
.settings-page {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f2eb;
  padding-bottom: 20px;
  box-sizing: border-box;
}

.settings-header {
  background: white;
  padding: 20px 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 3px 10px rgba(0,0,0,0.07);
}

.header-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.settings-content {
  margin: 10px 0;
  background: white;
  border-radius: 16px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.07);
  overflow: hidden;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #eee;
}

.settings-item:last-child {
  border-bottom: none;
}

.item-label {
  font-size: 16px;
  color: #333;
}

.arrow-icon {
  width: 20px;
  height: 20px;
  opacity: 0.5;
}

.logout-section {
  margin-top: 30px;
  padding: 0 15px;
}

.logout-button {
  width: 100%;
  height: 45px;
  background-color: #ff4d4f;
  color: white;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.logout-button::after {
  border: none;
}
</style>